// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ChartAndroidColor.java

package com.java4less.rchart.gc.android;

import android.graphics.Color;
import com.java4less.rchart.gc.ChartColor;

public class ChartAndroidColor extends ChartColor
{

	private int color;

	public ChartAndroidColor(Object c)
	{
		if (c instanceof String)
			setFromString((String)c);
		else
			color = ((Integer)c).intValue();
	}

	public ChartAndroidColor(int red, int green, int blue)
	{
		color = Color.rgb(red, green, blue);
	}

	public int getRed()
	{
		return Color.red(color);
	}

	public int getBlue()
	{
		return Color.blue(color);
	}

	public int getGreen()
	{
		return Color.green(color);
	}

	private void setRGB(int rgb)
	{
		int red = rgb >> 16 & 0xff;
		int green = rgb >> 8 & 0xff;
		int blue = rgb & 0xff;
		color = Color.rgb(red, green, blue);
	}

	private void setFromString(String c)
	{
		c = c.toUpperCase();
		if (c.compareTo(ChartColor.RED) == 0)
			color = 0xffff0000;
		else
		if (c.compareTo(ChartColor.BLACK) == 0)
			color = 0xff000000;
		else
		if (c.compareTo(ChartColor.BLUE) == 0)
			color = 0xff0000ff;
		else
		if (c.compareTo(ChartColor.CYAN) == 0)
			color = 0xff00ffff;
		else
		if (c.compareTo(ChartColor.DARKGRAY) == 0)
			color = 0xff444444;
		else
		if (c.compareTo(ChartColor.GRAY) == 0)
			color = 0xff888888;
		else
		if (c.compareTo(ChartColor.GREEN) == 0)
			color = 0xff00ff00;
		else
		if (c.compareTo(ChartColor.LIGHTGRAY) == 0)
			color = 0xffcccccc;
		else
		if (c.compareTo(ChartColor.MAGENTA) == 0)
			color = -65281;
		else
		if (c.compareTo(ChartColor.ORANGE) == 0)
			setRGB(0xff7500);
		else
		if (c.compareTo(ChartColor.PINK) == 0)
			setRGB(0xff75ff);
		else
		if (c.compareTo(ChartColor.WHITE) == 0)
			color = -1;
		else
		if (c.compareTo(ChartColor.YELLOW) == 0)
			color = -256;
		else
		if (c.compareTo(ChartColor.LIME) == 0)
			setRGB(65280);
		else
		if (c.compareTo(ChartColor.OLIVE) == 0)
			setRGB(0x808000);
		else
		if (c.compareTo(ChartColor.MAROON) == 0)
			setRGB(0x800000);
		else
		if (c.compareTo(ChartColor.NAVY) == 0)
			setRGB(128);
		else
		if (c.compareTo(ChartColor.PURPLE) == 0)
			setRGB(0x800080);
		else
		if (c.compareTo(ChartColor.TELA) == 0)
			setRGB(32896);
		else
		if (c.compareTo(ChartColor.FUCHSIA) == 0)
			setRGB(0xff00ff);
		else
		if (c.compareTo(ChartColor.AQUA) == 0)
			setRGB(65535);
		else
		if (c.compareTo(ChartColor.ALICEBLUE) == 0)
			setRGB(0xf0f8ff);
		else
		if (c.compareTo(ChartColor.ANTIQUEWHITE) == 0)
			setRGB(0xfaebd7);
		else
		if (c.compareTo(ChartColor.AQUAMARINE) == 0)
			setRGB(0x7fffd4);
		else
		if (c.compareTo(ChartColor.AZURE) == 0)
			setRGB(0xf0ffff);
		else
		if (c.compareTo(ChartColor.BEIGE) == 0)
			setRGB(0xf5f5dc);
		else
		if (c.compareTo(ChartColor.BLUEVIOLET) == 0)
			setRGB(0x8a2be2);
		else
		if (c.compareTo(ChartColor.BROWN) == 0)
			setRGB(0xa52a2a);
		else
		if (c.compareTo(ChartColor.BORLYWOOD) == 0)
			setRGB(0xdeb887);
		else
		if (c.compareTo(ChartColor.CORAL) == 0)
			setRGB(0xff7f50);
		else
		if (c.compareTo(ChartColor.CYAN) == 0)
			setRGB(65535);
		else
		if (c.compareTo(ChartColor.DARKGOLGENROD) == 0)
			setRGB(0xb8860b);
		else
		if (c.compareTo(ChartColor.DARKGREEN) == 0)
			setRGB(25600);
		else
		if (c.compareTo(ChartColor.DARKOLIVEGREEN) == 0)
			setRGB(0x556b2f);
		else
		if (c.compareTo(ChartColor.DARKORANGE) == 0)
			setRGB(0xff8c00);
		else
		if (c.compareTo(ChartColor.DARKORCHID) == 0)
			setRGB(0x9932cc);
		else
		if (c.compareTo(ChartColor.DARKSALMON) == 0)
			setRGB(0xe9967a);
		else
		if (c.compareTo(ChartColor.DARKTURQUOISE) == 0)
			setRGB(52945);
		else
		if (c.compareTo(ChartColor.DARKVIOLET) == 0)
			setRGB(0x9400d3);
		else
		if (c.compareTo(ChartColor.DEEPPINK) == 0)
			setRGB(0xff1493);
		else
		if (c.compareTo(ChartColor.DEEPSKYBLUE) == 0)
			setRGB(49151);
		else
		if (c.compareTo(ChartColor.FORESTGREEN) == 0)
			setRGB(0x228b22);
		else
		if (c.compareTo(ChartColor.GOLD) == 0)
			setRGB(0xffd700);
		else
		if (c.compareTo(ChartColor.GOLDENROD) == 0)
			setRGB(0xdaa520);
		else
		if (c.compareTo(ChartColor.GREENYELLOW) == 0)
			setRGB(0xadff2f);
		else
		if (c.compareTo(ChartColor.HOTPINK) == 0)
			setRGB(0xff69b4);
		else
		if (c.compareTo(ChartColor.INDIANRED) == 0)
			setRGB(0xcd5c5c);
		else
		if (c.compareTo(ChartColor.IVORY) == 0)
			setRGB(0xfffff0);
		else
		if (c.compareTo(ChartColor.KHALI) == 0)
			setRGB(0xf0e68c);
		else
		if (c.compareTo(ChartColor.LAVENDER) == 0)
			setRGB(0xe6e6fa);
		else
		if (c.compareTo(ChartColor.LAWNGREEN) == 0)
			setRGB(0x7cfc00);
		else
		if (c.compareTo(ChartColor.LIGHTBLUE) == 0)
			setRGB(0xadd8e6);
		else
		if (c.compareTo(ChartColor.LIGHTCORAL) == 0)
			setRGB(0xf08080);
		else
		if (c.compareTo(ChartColor.LIGHTCYAN) == 0)
			setRGB(0xe0ffff);
		else
		if (c.compareTo(ChartColor.LIGHTGRAY) == 0)
			setRGB(0xd3d3d3);
		else
		if (c.compareTo(ChartColor.LIGHTPINK) == 0)
			setRGB(0xffb6c1);
		else
		if (c.compareTo(ChartColor.LIGHTSALMON) == 0)
			setRGB(0xffa07a);
		else
		if (c.compareTo(ChartColor.LIGHTSKYBLUE) == 0)
			setRGB(0x87cefa);
		else
		if (c.compareTo(ChartColor.LIGHTYELLOW) == 0)
			setRGB(0xffffe0);
		else
		if (c.compareTo(ChartColor.LIMEGREEN) == 0)
			setRGB(0x32cd32);
		else
		if (c.compareTo(ChartColor.MAGENTA) == 0)
			setRGB(0xff00ff);
		else
		if (c.compareTo(ChartColor.MEDIUMBLUE) == 0)
			setRGB(205);
		else
		if (c.compareTo(ChartColor.MEDIUMPURPLE) == 0)
			setRGB(0x9370db);
		else
		if (c.compareTo(ChartColor.MIDNIGHTBLUE) == 0)
			setRGB(0x191970);
		else
		if (c.compareTo(ChartColor.ORANGE) == 0)
			setRGB(0xffa500);
		else
		if (c.compareTo(ChartColor.ORANGERED) == 0)
			setRGB(0xff4500);
		else
		if (c.compareTo(ChartColor.ORCHID) == 0)
			setRGB(0xda70d6);
		else
		if (c.compareTo(ChartColor.PALEGREEN) == 0)
			setRGB(0x98fb98);
		else
		if (c.compareTo(ChartColor.PALETURQUOISE) == 0)
			setRGB(0xafeeee);
		else
		if (c.compareTo(ChartColor.PALEVIOLETRED) == 0)
			setRGB(0xdb7093);
		else
		if (c.compareTo(ChartColor.PINK) == 0)
			setRGB(0xffc0cb);
		else
		if (c.compareTo(ChartColor.PLUM) == 0)
			setRGB(0xdda0dd);
		else
		if (c.compareTo(ChartColor.PURPLE) == 0)
			setRGB(0xa020f0);
		else
		if (c.compareTo(ChartColor.SALMON) == 0)
			setRGB(0xfa8072);
		else
		if (c.compareTo(ChartColor.SEAGREEN) == 0)
			setRGB(0x2e8b57);
		else
		if (c.compareTo(ChartColor.SIENNA) == 0)
			setRGB(0xa0522d);
		else
		if (c.compareTo(ChartColor.SKYBLUE) == 0)
			setRGB(0x87ceeb);
		else
		if (c.compareTo(ChartColor.SPRINGGREEN) == 0)
			setRGB(65407);
		else
		if (c.compareTo(ChartColor.TURQUOISE) == 0)
			setRGB(0x40e0d0);
		else
		if (c.compareTo(ChartColor.VIOLET) == 0)
			setRGB(0xee82ee);
		else
		if (c.compareTo(ChartColor.YELLOWGREEN) == 0)
			setRGB(0x9acd32);
		else
			try
			{
				int rgb = 0;
				c = c.toUpperCase();
				if (c.startsWith("0X"))
					rgb = Integer.parseInt(c.substring(2), 16);
				else
				if (c.startsWith("X"))
					rgb = Integer.parseInt(c.substring(1), 16);
				else
					rgb = Integer.parseInt(c);
				setRGB(rgb);
			}
			catch (Exception e)
			{
				e.printStackTrace();
				color = 0xff000000;
			}
	}

	public int getColor()
	{
		return color;
	}

	public ChartColor darker()
	{
		int percent = 10;
		int rr = getRed();
		int gg = getGreen();
		int bb = getBlue();
		int r = rr - percent * (rr / 100);
		int g = gg - percent * (gg / 100);
		int b = bb - percent * (bb / 100);
		return new ChartAndroidColor(Math.min(r, 255), Math.min(g, 255), Math.min(b, 255));
	}

	public ChartColor brighter()
	{
		int percent = 10;
		int rr = getRed();
		int gg = getGreen();
		int bb = getBlue();
		int r = rr + percent * (rr / 100);
		int g = gg + percent * (gg / 100);
		int b = bb + percent * (bb / 100);
		return new ChartAndroidColor(Math.min(r, 255), Math.min(g, 255), Math.min(b, 255));
	}
}
